<%--
  Created by IntelliJ IDEA.
  User: cz
  Date: 2021/8/12
  Time: 15:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>图书系统首页</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="js/jquery-3.6.0.js"></script>
</head>
<body style="background-color: rgba(174,174,174,0.55)">
<div class="page-header">
    <h1>图书管理界面</h1>
</div>

<table class="table table-striped">
    <thead>
    <tr>
        <th>id</th>
        <th>图书名称</th>
        <th>作者</th>
        <th>出版社</th>
        <th>出版时间</th>
        <th>操作</th>
    </tr>
    </thead>

    <tbody id="tbody">
    </tbody>
</table>

<a href="/main.jsp" class="btn btn-default btn-lg active" role="button">返回</a>

</body>
</html>
<script>
    $(function () {
        //获取页面初始化值
        getData();
    });

    function getData() {
        //获取页面初始化值
        $.getJSON("bookSystem.do",{flag:"borrowed"},function (result) {
            init(result);
        })
    }

    function init(data) {
        console.log(data);
        var data_length = data.length;
        for (var i = 0;i<data_length;i++){
            $("#tbody").append("<tr>" +
                "<td>" +data[i].bookId+"</td>"+
                "<td>" +data[i].bookName+"</td>"+
                "<td>" +data[i].author+"</td>"+
                "<td>" +data[i].publisher+"</td>"+
                "<td>" +data[i].pubDate+"</td>"+
                "<td><a href='/bookSystem.do?flag=return&bookId="+data[i].bookId+"' class='btn btn-default btn-lg active' role='button'>归还</a></td>" +
                "</tr>");
        }
    }

</script>
